#include using namespace std; //string - a word or phrase stored in a variable //(a list of characters that to be viewed as one) void main() { int a[10] = {1,2,3,4,5,6,7,8}; // char name[10] = {'E','m','m','a'}; char name[10] = "Emma"; // you and only initialize like this at the declaration char name2[7] = "Elijah"; // you and only initialize like this at the declaration //"A" - this is two chars, A and a '\0', it makes a c-style string //'A' - this is just the char A // name = name2; //do not try to copy any list like this ////when you try to display an array like this you will just get the address //cout << a << endl; ////to diplay the values in an array you must do it one element at a time //for(int i = 0; i < 10; i++) //{ // //the [] after a pointer to tell the program to use the value at the address // //plus the subscript (using pointer arithmetic) // cout << a[i]; //} //cout << endl; //char pointers are special //when the address of a char is sent to standared output //all of the the characters from that address forward are displayed //it stops dispaying characters when it gets to a char with the ascii value 0 //the char with the ascii value 0 is known as the "null character" // a.k.a the "null terminator" //it is used to mark the end of "c-style strings" // '\0' - the escape sequence for the null terminator cout << name << endl; //c-style string - in the c & c++ programming language it is an array of // charcters with a null terminator, intended to be used as a string //for(int i = 0; i < 10; i++) //{ // cout << name[i]; //} //cout << endl; char junk[5] = {'a','b','c','d','e'}; cout << (junk + 1) << endl; }